package unq.uis.robots.ui;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.layout.HorizontalLayout;
import org.uqbar.arena.layout.VerticalLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.windows.Dialog;
import org.uqbar.arena.windows.WindowOwner;

import unq.uis.robots.applicationsModels.VenderRobotApplicationModel;


public class VenderRobotWindow extends Dialog<VenderRobotApplicationModel> {

	private static final long serialVersionUID = 1L;
	
	public VenderRobotWindow(WindowOwner owner, VenderRobotApplicationModel model) {
		super(owner, model);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected void createFormPanel(Panel mainPanel) {
		this.setTitle("Vender");
		Panel panel = new Panel(mainPanel);
		panel.setLayout(new VerticalLayout());
		
		Panel panel1 = new Panel(panel);
		panel1.setLayout(new HorizontalLayout());
		
		Label name = new Label(panel1);
		name.setText("Nombre: ");
		
		Label nombre = new Label(panel1);
		nombre.bindValueToProperty("robotAVender.nombre");
		
		
		Panel panel2 = new Panel(panel);
		panel2.setLayout(new HorizontalLayout());
		
		Label name2 = new Label(panel2);
		name2.setText("Deterioro: ");
		
		Label danio = new Label(panel2);
		danio.bindValueToProperty("robotAVender.danio");
		
		
		Panel panel3 = new Panel(panel);
		panel3.setLayout(new HorizontalLayout());
		
		Label name3 = new Label(panel3);
		name3.setText("Precio Original: ");
		
		Label precio = new Label(panel3);
		precio.bindValueToProperty("robotAVender.precioBase");
		
	
		Panel panel4 = new Panel(panel);
		panel4.setLayout(new HorizontalLayout());
		
		Label name4 = new Label(panel4);
		name4.setText("OFERTA:");
		
		Label oferta = new Label(panel4);
		oferta.bindValueToProperty(VenderRobotApplicationModel.OFERTADELSISTEMA);
		
	}
	
	public void notificarRechazoDeOferta(){
		this.getModelObject().rechazarOferta();
		this.showMessageBox("Su robot se ha desgastado debido a que el sistema rechazo la oferta", 1);
	}
	
	@Override
	protected void addActions(Panel actions) {
		new Button(actions)
			.setCaption("Aceptar")
			.onClick(new MessageSend(this, "accept"))
			.setAsDefault()
			.disableOnError();

		new Button(actions)
			.setCaption("Cancelar")
			.onClick(new MessageSend(this, "cancel"));
	}

}
